#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;

void solve() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int s1 = 0, s2 = 0, s3 = 0, s4 = 0;
	for(int i = 0; i < n; i++) {
		if(i & 1) {
			s1 += s[i] == '1';
			s3 += t[i] == '0';
		}else{
			s2 += s[i] == '1';
			s4 += t[i] == '0';
		}
	}
	if(s3 >= s2 && s4 >= s1) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
}

signed main() {
	int t = 1;
	cin >> t;
	while(t--) solve();
	return 0;
}